package com.hadron.media.slideshow.items 
{
	import com.greensock.loading.data.SWFLoaderVars;
	import com.greensock.loading.SWFLoader;
	import com.greensock.events.LoaderEvent;
	/**
	 * ...
	 * @author Hadron
	 */
	public class SlideshowSwfItem extends AbstractSlideshowItem
	{
		private  var _url:String;
		
		public function SlideshowSwfItem($url:String) 
		{
			super();
			
			_url = $url;
			var vars:SWFLoaderVars = new SWFLoaderVars()
										.container(this)
										.onComplete(handleContent)
										.noCache(false);
										
			//instantiate protected loader var
			_loader = new SWFLoader(_url, vars);
		}
		
		override public function transitionIn():void
		{
			super.transitionIn();
			content.gotoAndPlay(2);
			transitionBehavior.transitionIn();
		}
		
		protected function handleContent(e:LoaderEvent):void 
		{
			//logDebug('image loaded');
			_loader.removeEventListener(LoaderEvent.COMPLETE, handleContent);
			content = _loader.rawContent;
		}
		
		override public function set content(value:*):void
		{
			super.content = value;
			addChild(content);
		}
		
		override public function get loader():*
		{			
			return _loader as SWFLoader;
		}
	}
}